<script setup>
import { inject } from 'vue';
import GrandSonVue from './GrandSon.vue';

// 拿到传家宝
// 数据 = inject('接受的数据名')
const treasure = inject('treasure')

// 拿到花钱的方法, 花钱
const costMoney = inject('costMoney')
const cost = () => costMoney(10)
</script>

<template>
  <div style="border:10px solid #333">
    <h1>我是子组件</h1>
    <span> {{ treasure }} </span>
    <button @click="cost">花钱</button>
    <GrandSonVue />
  </div>
</template>